<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<![endif]-->
<title>VIM 中文帮助: Zip 归档探索器</title>
<link rel="stylesheet" href="vim-stylesheet.css" type="text/css" />
<link rel="canonical" href="https://yianwillis.github.io/vimcdoc/doc/pi_zip.html" />
<script type="text/javascript" src="vimcdoc.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<nav id=banner>
<form action=tags.html target="tag_iframe">
  <input type="text" name="tag" id="tag" placeholder="标签搜索">
</form>
<iframe name="tag_iframe" src=""></iframe>
<a href="help.html">帮助总览</a> &middot;
<hr/>
<a href="quickref.html">快速参考</a> &middot;
<a href="index.html">命令索引</a> &middot;
<a href="eval.html#functions">函数列表</a> &middot;
<a href="quickref.html#option-list">选项列表</a> &middot;
<hr/>
<a href="usr_toc.html">用户手册</a> &middot;
<a href="help.html#reference_toc">参考手册</a> &middot;
</nav>

<header>
<h2>pi_zip</h2>
</header>
<article id=outer>
<section class=inner>
<b class="vimtag"> <a name="pi_zip.txt">pi_zip.txt</a> </b>    适用于 Vim 9.0 版本。   最近更新: 2022年7月

                                +====================+
                                |    Zip 文件接口    |
                                +====================+
                                <code class="vim">译者</code>: Willis

Author:  Charles E. Campbell  &lt;NcampObell@SdrPchip.AorgM-NOSPAM&gt;
          (remove NOSPAM from Campbell's email first)
Copyright: Copyright (C) 2005-2015 Charles E Campbell <b class="vimtag"> <a name="zip-copyright">zip-copyright</a> </b>
        The VIM LICENSE (see  <a href="uganda.html#copyright">copyright</a> ) applies to the files in this
        package, including zipPlugin.vim, zip.vim, and pi_zip.vim.  except use
        "zip.vim" instead of "VIM".  Like anything else that's free, zip.vim
        and its associated files are provided *as is* and comes with no
        warranty of any kind, either expressed or implied.  No guarantees of
        merchantability.  No guarantees of suitability for any purpose.  By
        using this plugin, you agree that in no event will the copyright
        holder be liable for any damages resulting from the use of this
        software. Use at your own risk!

</section><hr class="doubleline" /><section class=inner>
<h4>1. 内容                                                 <b class="vimtag"> <a name="zip">zip</a> </b> <b class="vimtag"> <a name="zip-contents">zip-contents</a> </b></h4>   1. 内容.................................................... <a href="pi_zip.html#zip-contents">zip-contents</a> 
   2. 用法.................................................... <a href="pi_zip.html#zip-usage">zip-usage</a> 
   3. 附加扩展名.............................................. <a href="pi_zip.html#zip-extension">zip-extension</a> 
   4. 历史.................................................... <a href="pi_zip.html#zip-history">zip-history</a> 

</section><hr class="doubleline" /><section class=inner>
<h4>2. 用法                                                 <b class="vimtag"> <a name="zip-usage">zip-usage</a> </b> <b class="vimtag"> <a name="zip-manual">zip-manual</a> </b></h4>
   编辑 *.zip 文件时，此插件进行处理，显示内容页面。移动光标到文件上，然后按
   <code class="special">&lt;return&gt;</code> 键，就可以选择该文件进行编辑。编辑后，可以写回该文件。目前，不能用
   该插件建立新的 zip 归档文件。

                                                                <b class="vimtag"> <a name="zip-x">zip-x</a> </b>
   x : 光标在列出文件名上时提取此文件

   选 项

                                                        <b class="vimtag"> <a name="g:zip_nomax">g:zip_nomax</a> </b>

   如果此变量存在且为真，文件窗口在打开时不会自动最大化。

                                                        <b class="vimtag"> <a name="g:zip_shq">g:zip_shq</a> </b>
   不同的操作系统可能使用一个或多个外壳来执行命令。Zip 试图猜测正确的引号使用
   机制，使得文件名中可以包含空格和其它；如果猜错了，可用 
<code class="example">        g:zip_shq</code>
   修正。它在 Unix 上缺省是单引号 (')，而 Windows 上缺省是双引号 (")。如果你希
   望不用引号，简单地在 &lt;.vimrc&gt; 里把 g:zip_shq 置为空串 (let g:zip_shq= "")。

                                                        <b class="vimtag"> <a name="g:zip_unzipcmd">g:zip_unzipcmd</a> </b>
   用此选项指定执行 "unzip" 任务的程序，用于浏览。缺省: 
<code class="example">        let g:zip_unzipcmd= "unzip"</code>

                                                        <b class="vimtag"> <a name="g:zip_zipcmd">g:zip_zipcmd</a> </b>
   用此选项指定执行 "zip" 任务的程序，用于写入 (更新) 已在 zip 包中的文件；缺
   省: 
<code class="example">        let g:zip_zipcmd= "zip"</code>

                                                        <b class="vimtag"> <a name="g:zip_extractcmd">g:zip_extractcmd</a> </b>
   用此选项指定程序 (和所需的选项)，用于从 zip 归档文件提取文件。缺省 
<code class="example">        let g:zip_extractcmd= g:zip_unzipcmd</code>

<code class="section">   禁 止 载 入</code>

   如果由于某种原因你不想 vim 检查 zip 文件，在 &lt;.vimrc&gt; 中定义两个变量就可以
   不载入 zip 插件: 
<code class="example"></code>
<code class="example">        let g:loaded_zipPlugin= 1</code>
<code class="example">        let g:loaded_zip      = 1</code>


</section><hr class="doubleline" /><section class=inner>
<h4>3. 附加扩展名                                                   <b class="vimtag"> <a name="zip-extension">zip-extension</a> </b></h4>
   看来有不少归档程序生成 zip 文件但不使用 .zip 扩展名 (.jar、.xpi 等)。要处理
   这些文件，在 &lt;.vimrc&gt; 文件中放上: 
<code class="example"></code>
<code class="example">        au BufReadCmd *.jar,*.xpi call zip#Browse(expand("&lt;amatch&gt;"))</code>

   你可以自由扩展该行以包含更多应被当作 zip 文件的扩展名。

   此外，也可以在 .vimrc 里改变 <b class="vimtag"> <a name="g:zipPlugin_ext">g:zipPlugin_ext</a> </b> 。 当前 (11/30/15) 包含了: 
<code class="example"></code>
<code class="example">        let g:zipPlugin_ext= '*.zip,*.jar,*.xpi,*.ja,*.war,*.ear,*.celzip,</code>
<code class="example">       \ *.oxt,*.kmz,*.wsz,*.xap,*.docx,*.docm,*.dotx,*.dotm,*.potx,*.potm,</code>
<code class="example">       \ *.ppsx,*.ppsm,*.pptx,*.pptm,*.ppam,*.sldx,*.thmx,*.xlam,*.xlsx,*.xlsm,</code>
<code class="example">       \ *.xlsb,*.xltx,*.xltm,*.xlam,*.crtx,*.vdw,*.glox,*.gcsx,*.gqsx,*.epub'</code>
<code class="example"></code>
</section><hr class="doubleline" /><section class=inner>
<h4>4. 历史 (英文)                                                  <b class="vimtag"> <a name="zip-history">zip-history</a> </b> {{{1</h4>   v32 Oct 22, 2021 * to avoid an issue with a vim 8.2 patch, zipfile: has
                      been changed to zipfile:// . This often shows up
                      as zipfile:/// with zipped files that are root-based.
   v29 Apr 02, 2017 * (Klartext) reported that an encrypted zip file could
                      opened but the swapfile held unencrypted contents.
                      The solution is to edit the contents of a zip file
                      using the  <a href="recover.html#:noswapfile">:noswapfile</a>  modifier.
   v28 Oct 08, 2014 * changed the sanity checks for executables to reflect
                      the command actually to be attempted in zip#Read()
                      and zip#Write()
                    * added the extraction of a file capability
       Nov 30, 2015 * added *.epub to the  <a href="pi_zip.html#g:zipPlugin_ext">g:zipPlugin_ext</a>  list
       Sep 13, 2016 * added *.apk to the  <a href="pi_zip.html#g:zipPlugin_ext">g:zipPlugin_ext</a>  list and
                      sorted the suffices.
   v27 Jul 02, 2013 * sanity check: zipfile must have "PK" as its first
                      two bytes.
                    * modified to allow zipfile: entries in quickfix lists
   v26 Nov 15, 2012 * (Jason Spiro) provided a lot of new extensions that
                      are synonyms for .zip
   v25 Jun 27, 2011 * using keepj with unzip -Z
                      (consistent with the -p variant)
                    * (Ben Staniford) now uses
                        has("win32unix") &amp;&amp; executable("cygpath")
                      before converting to cygwin-style paths
   v24 Jun 21, 2010 * (Cédric Bosdonnat) unzip seems to need its filenames
                      fnameescape'd as well as shellquote'd
                    * (Motoya Kurotsu) inserted keepj before 0d to protect
                      jump list
   v17 May 09, 2008 * arno caught a security bug
   v15 Sep 07, 2007 * &amp;shq now used if not the empty string for g:zip_shq
   v14 May 07, 2007 * using b:zipfile instead of w:zipfile to avoid problem
                      when editing alternate file to bring up a zipfile
   v10 May 02, 2006 * now using "redraw then echo" to show messages, instead
                      of "echo and prompt user"
                    * g:zip_shq provided to allow for quoting control for the
                      command being passed via :r! ... commands.
   v8 Apr 10, 2006 * Bram Moolenaar reported that he received an error message
                     due to "Pattern not found: ^.*\%0c"; this was caused by
                     stridx finding a Name... at the beginning of the line;
                     zip.vim tried 4,$s/^.*\%0c//, but that doesn't work.
                     Fixed.
   v7 Mar 22, 2006 * escaped some characters that can cause filename handling
                     problems.
   v6 Dec 21, 2005 * writing to files not in directories caused problems -
                     fixed (pointed out by Christian Robinson)
   v5 Nov 22, 2005 * report option workaround installed
   v3 Oct 18, 2005 * <code class="special">&lt;amatch&gt;</code> used instead of <code class="special">&lt;afile&gt;</code> in autocmds
   v2 Sep 16, 2005 * silenced some commands (avoiding hit-enter prompt)
                   * began testing under Windows; works thus far
                   * filetype detection fixed
      Nov 03, 2005 * handles writing zipfiles across a network using
                     netrw#NetWrite()
   v1 Sep 15, 2005 * Initial release, had browsing, reading, and writing

</section><hr class="doubleline" /><section class=inner>
<h4>vim:tw=78:ts=8:ft=help:noet:norl:fdm=marker</h4></section>
</article>
<footer>
Generated by vim2html
</footer>
</body>
</html>
